package com.dream.myqiyi.service.impl;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.dream.myqiyi.dao.NoteResourceModel;
import com.dream.myqiyi.service.NoteResourceManager;
import com.j256.ormlite.dao.Dao;

public class NoteResourceManagerImpl extends GenericManagerImpl<NoteResourceModel, String> implements NoteResourceManager{
	Dao<NoteResourceModel, String> noteResourceDao;
	
	public NoteResourceManagerImpl(Dao<NoteResourceModel, String> noteResourceDao) {
        super(noteResourceDao);
        this.noteResourceDao = noteResourceDao;
    }

	@Override
	public List<NoteResourceModel> findByNoteGuid(String notegui) {
		Map<String, Object> filedValues = new HashMap<String, Object>(); 
		filedValues.put("noteGuid", notegui);
		try {
			return noteResourceDao.queryForFieldValues(filedValues);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return null;
	}

	public void removeByNoteGuid(String noteguid) {
		List<NoteResourceModel> nrmList =  findByNoteGuid(noteguid);
		try {
			noteResourceDao.delete(nrmList);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
